<html>
<body>

<button id="link1" onclick="openPdf()">Click me to load pdf</button>
<div id="container"></div>

<script>
function openPdf() {
  var frame = document.createElement("iframe");
  frame.src = "test.pdf";
  document.getElementById("container").appendChild(frame);
}
</script>

<body>
</html>